<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="./luxon.js"></script>
<script>
    var DateTime = luxon.DateTime;
    var Settings = luxon.Settings
    // Settings.defaultZone = "Asia/Tokyo";
    // Settings.defaultZone = "utc";
    // Settings.defaultZone = "system";
    // console.log(DateTime.fromSQL('2022-02-15 00:00:00'), DateTime.fromSQL('2022-02-15 00:00:00').ts)
    // Settings.defaultZone = "UTC+08:00";
    // console.log(DateTime.fromSQL('2022-02-15 00:00:00'), DateTime.fromSQL('2022-02-15 00:00:00').ts)
    // Settings.defaultZone = "UTC+00:00";
    // console.log(DateTime.fromSQL('2022-02-15 00:00:00'), DateTime.fromSQL('2022-02-15 00:00:00').ts)
    // Settings.defaultZone = "UTC+00:10";
    // console.log(DateTime.fromSQL('2022-02-15 00:00:00'), DateTime.fromSQL('2022-02-15 00:00:00').ts)
    // Settings.defaultZone = "UTC-00:10";
    // console.log(DateTime.fromSQL('2022-02-15 00:00:00'), DateTime.fromSQL('2022-02-15 00:00:00').ts)
    // Settings.defaultZone = "UTC+8.5";// 无效写法
    // console.log(DateTime.fromSQL('2022-02-15 00:00:00'), DateTime.fromSQL('2022-02-15 00:00:00').ts)
    // console.log(Settings.defaultZone)
    // dt.year     //=> 2017
    // dt.month    //=> 9
    // dt.day      //=> 14
    // dt.second   //=> 47
    // dt.weekday  //=> 4
    // console.log('year', dt.year)
    // console.log('month', dt.month)
    // console.log('day', dt.day)
    // console.log('hour', dt.hour)
    // console.log('minute', dt.minute)
    // console.log('second', dt.second)
    // console.log('weekday', dt.weekday)
    // console.log('zoneName', dt.zoneName)
    // console.log('offset', dt.offset)
    // console.log('daysInMonth', dt.daysInMonth)
    // console.log(DateTime.local(null))
    // console.log(DateTime.local('2022-02-14 23:59:59.999'))
    // console.log(DateTime.local('2022-02-14 00:00:00'))
    // console.log(DateTime.local('2022', '02', '14'))
    // console.log(new DateTime('2022-02-14 00:00:00'))
    // console.log(new DateTime('2022-02-14 23:59:59.999'))
    // console.log(DateTime.fromSQL('2022-02-14 00:00:00'))
    // console.log(DateTime.fromSQL('2022/02/14 00:00:00'))
    // console.log(DateTime.fromSQL('2022-02-14 23:59:59.999'))
    // console.log(DateTime.local(2022, 2, 14, 0, 0, 0))
    // console.log(DateTime.local(2022, 2, 14, 23, 59, 59, 999))
    // console.log(new Date('2022-02-14 00:00:00').getTime())
    // console.log(new Date('2022-02-14 23:59:59.999').getTime())
    // console.log(DateTime.fromMillis(new Date('2022-02-14 00:00:00').getTime()))
    // console.log(DateTime.local(2022))
    // let time = 2022
    // console.log(DateTime.local(time))
    // console.log(DateTime.fromMillis(time))
    // console.log(DateTime.fromSQL(time))
    // console.log(DateTime.fromSQL('2022-1-01 00:00:00'))
    // console.log(DateTime.fromSQL('2022-01-01 00:00:00'))

    // const dt1 = DateTime.local(2017, 5, 15, 8, 30);
    // const dt2 = DateTime.fromObject({day: 22, hour: 12 }, { zone: 'America/Los_Angeles', numberingSystem: 'beng'})
    // const dt3 = DateTime.fromISO("2017-05-15T08:30:00")
    // const now = DateTime.now();

    // DateTime.now().toString(); //=> '2017-09-14T03:20:34.091-04:00'

    // var dt = DateTime.now();
    // dt.plus({ hours: 3, minutes: 2 });
    // dt.minus({ days: 7 });
    // dt.startOf('day');
    // dt.endOf('hour');

    // var dt = DateTime.now();
    // dt.set({hour: 3}).hour

    // DateTime.fromObject({}, {zone: 'America/Los_Angeles'}); // now, but expressed in LA's local time
    // DateTime.now().setZone("America/Los_Angeles"); // same

    // console.log(now)
    // console.log(now.ts)
    // console.log(new Date().getTime())

    // console.log(dt1)
    // console.log(dt2)
    // console.log(dt3)

    // console.log(DateTime.now().setZone("America/Los_Angeles"))
    // console.log(DateTime.now())
    // console.log(DateTime.now().setZone("America/Los_Angeles").ts)
    // console.log(DateTime.now().ts)
    // console.log(Date.now())
    // console.log(new Date().getTime())
    // Settings.defaultZone = "utc";
    // console.log(DateTime.local().ts)

    // const dateTime = new Date()

    // 切换
    // newDate()
    // getTime()
    // getTime2()
    // dateTimeFilter
    // getDateTime
    // getOffsetDateTime

    // function handlerSqlString(val) {
    //     const [_date, _time] = val.split(' ')
    //     // eslint-disable-next-line prefer-const
    //     let [year, month, date] = _date.split('-')
    //     month = month < 10 ? '0' + +month : month
    //     date = date < 10 ? '0' + +date : date
    //     return `${year}-${month}-${date}${_time ? ' ' + _time : ''}`
    // }
    //
    // console.log(handlerSqlString('2022-1-01'))
    // console.log(handlerSqlString('2022-1-01 00:00:00'))

    // console.log(DateTime.now().toFormat('yyyy-MM-dd'))

    Settings.defaultZone = "UTC+08:00";
    const ts1 = DateTime.fromMillis(1645372799000)
    console.log(ts1, ts1.hour, ts1.minute, ts1.second)
    const ts2 = DateTime.fromMillis(1645372799000 + 24 * 60 * 60 * 1000)
    console.log(ts2, ts2.hour, ts2.minute, ts2.second)
    // const t3 = DateTime.fromSQL('2022-02-15 00:00:00')
    // console.log(t3)
</script>
</body>
</html>